﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace QuanLiBongDa.DataAccessLayer
{
    class DoiBongDAO
    {
        public static DoiBongDAO CreateDoiBongDAO()
        {
            return new DoiBongDAO();
        }
        public bool Insert_DoiBong(DoiBongDTO d)
        {
            SqlParameter[] par = new SqlParameter[3];
            par[0] = new SqlParameter("@MaDoi", d.MaDoi);
            par[1] = new SqlParameter("@TenDoi", d.TenDoi);
            par[2] = new SqlParameter("@MaSan",d.MaSan);
            return SQLService.mmExecuteNonquery("Insert_DoiBong", par);
        }
        public bool Update_DoiBong(DoiBongDTO d)
        {
            SqlParameter[] par = new SqlParameter[3];
            par[0] = new SqlParameter("@MaDoi", d.MaDoi);
            par[1] = new SqlParameter("@TenDoi", d.TenDoi);
            par[2] = new SqlParameter("@MaSan", d.MaSan);
            return SQLService.mmExecuteNonquery("Update_DoiBong", par);
        }
        public bool Delete_DoiBong(DoiBongDTO d)
        {
            SqlParameter[]par=new SqlParameter[1];
            par[0] = new SqlParameter("@MaDoi", d.MaDoi);
            return SQLService.mmExecuteNonquery("Delete_DoiBong", par);        }
        public void MaSan(ComboBox masan)
        {
            SqlDataReader dr = SQLService.mExecuteReader(SQLService.ReturnAll("SAN"));
            while (dr.Read())
            {
                masan.Items.Add(dr["TenSan"]);
            }
        }
        public DataTable TimMD_Ten(string tendoi)
        {
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@TenDoi", tendoi);
            return SQLService.FillTable("TimMD_Ten", par);
        }
    }

}
